package com.HomeWorkhsp.chapter15.generic;

public class MyDate {

    private int month;
    private int day;
    private int year;

    public MyDate(int month, int day, int year) {
        this.month = month;
        this.day = day;
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int compareTo(MyDate m2){
        int yearMinus = year - m2.getYear();
        if (yearMinus != 0)
            return yearMinus;
        int monthMinus = month - m2.getMonth();
        if (monthMinus != 0)
            return monthMinus;
        return day - m2.getDay();
    }

    @Override
    public String toString() {
        return "MyDate{" +
                "month=" + month +
                ", day=" + day +
                ", year=" + year +
                '}';
    }
}

